import { reqCategoryList, reqBannerList, reqFloorList } from "@/api/home";
const state = {
  caregoryList: [],
  bannerList: [],
  floorList: [],
};
const mutations = {
  //存储三级联动的数据
  CATEGORYLIST(state, caregoryList) {
    state.caregoryList = caregoryList;
  },
  //获取bannerlist的数据
  BANNERLIST(state, bannerList) {
    state.bannerList = bannerList;
  },
  //获取floor数据
  GETFLOORLIST(state, floorList) {
    state.floorList = floorList;
  },
};
const actions = {
  //获取三级联动的数据
  async caregoryList({ commit }) {
    let res = await reqCategoryList();
    // console.log(res);
    if (res.code == 200) {
      commit("CATEGORYLIST", res.data);
    }
  },
  //获取banner数据
  async bannerList({ commit }) {
    let res = await reqBannerList();
    // console.log(res);
    if (res.code == 200) {
      commit("BANNERLIST", res.data);
    }
  },
  //获取floor数据
  async getFloorList({ commit }) {
    let res = await reqFloorList();
    // console.log(res);
    if (res.code == 200) {
      commit("GETFLOORLIST", res.data);
    }
  },
};
const getters = {};
export default {
  state,
  mutations,
  actions,
  getters,
};
